package com.xzj.admin.analysis.base.custom.ty;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.xzj.admin.analysis.base.common.handle.CommonAbstractAnalysisHandle;
import lombok.extern.slf4j.Slf4j;

/**
 * @program: xzj-admin
 * @ClassName: ZyyAnalysisHandle
 * @description: 天翼自研云
 * @author: XiaZunJun
 * @create: 2024-11-12 22:17
 */
@Slf4j
public class ZyyAnalysisHandle extends CommonAbstractAnalysisHandle {

    static {
        registerJudgeSubFun("physicalHost", ZyyAnalysisHandle::physicalHostSubResource);
        registerJudgeSubFun("virtualHost", TyCommonHandle::virtualHostSubResource);
        registerJudgeSubFun("virtualComputer", TyCommonHandle::virtualHostSubResource);
        registerJudgeSubFun("virtualVolume", TyCommonHandle::virtualVolumeSubResource);
        registerJudgeSubFun("virtualStoragePool", TyCommonHandle::virtualStoragePoolSubResource);
    }

    public ZyyAnalysisHandle(String cloudId,String cloudType) {
        super(cloudId, cloudType,new TyyThemeSpecialAnalysisHandle(cloudId, cloudType));
    }

    private static void physicalHostSubResource(JSONObject row, String parentId, String fieldName,
                                                JSONArray subThemeRows) {
        if ("poolList".equals(fieldName)) {
            TyCommonHandle.physicalHostPoolListSub(row, parentId, fieldName, subThemeRows);
        } else {
            TyCommonHandle.physicalHostAfterSalesSub(row, parentId,fieldName, subThemeRows);
        }
    }

}
